<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 预习 v-bind -->
        <!-- 计算属性 computed -->
        <!-- 监听器 watch  -->
        <img v-bind:src="url" alt="" style="width: 200px; height: 200px;">
        <br>
        <button v-on:click="handleUp">上一张</button>
        <button v-on:click="handleDown">下一张</button>
    </div>





</body>
<script>
    let vm = new Vue({
        el: "#app",
        data: {
            imgs: ["https://i04piccdn.sogoucdn.com/6c9827a586b83070", "https://socialbeta.oss-cn-hangzhou.aliyuncs.com/upload/198246-1703820780.jpg", "https://5b0988e595225.cdn.sohucs.com/images/20191020/70766c1459d24b7893a82e0905dd16bd.jpeg", "https://img1.mydrivers.com/img/20240613/a9030e59-c056-4116-b5c3-954de699d651.png"],
            url: 'https://i04piccdn.sogoucdn.com/6c9827a586b83070',
            index: 0
        },
        methods: {
            handleUp() {
                 if(this.index==0){
                    this.index=3
                }
                this.url = this.imgs[this.index--]
            },
            handleDown() {
              
                    this.url = this.imgs[this.index++]
                if(this.index==3){
                    this.index=0
                }
            }
        }
    })
</script>

</html>